import Vue from "vue";
import VModal from 'vue-js-modal';
Vue.use(VModal,{dialog:true});

const dialog = {};

dialog.alert = function(vm,text){
    vm.$modal.show('dialog',{
        text:text,
        buttons:[
            {title:'关闭'}
        ]
    });
}

dialog.confirm = function(vm,text,call){
    vm.$modal.show('dialog',{
        text:text,
        buttons:[
            {
                title: '取消',
                handler:function(){
                    vm.$modal.hide('dialog');
                    call(false);
                }
            },
            {
                title: '确认',
                default: true,
                handler:function(){
                    vm.$modal.hide('dialog');
                    call(true);
                }
            }
        ]
    });
}

export default dialog;